package com.tentative.competition.web.controller.schedule.service;

import com.tentative.competition.common.core.controller.BaseController;
import com.tentative.competition.common.core.domain.AjaxResult;
import com.tentative.competition.common.core.result.ApiResult;
import com.tentative.competition.common.core.result.PageResult;
import com.tentative.competition.common.model.schedule.param.AwardAddParam;
import com.tentative.competition.common.model.schedule.resp.AwardResp;
import com.tentative.competition.schedule.service.ScheduleAwardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @auther: Smile Huang
 * @date: 2023/6/24 22:08
 * @desc:
 * @version: 2.0
 */
@Api(tags = "service-奖项业务")
@RestController
@RequestMapping("/service/award")
public class AwardController extends BaseController {

    @Autowired
    private ScheduleAwardService awardService;

    @ApiOperation("查询奖项配置列表-分页")
    @GetMapping("/list")
    public ApiResult list(AwardAddParam param) {
        PageResult<AwardResp> list = awardService.pageList(param);
        return ApiResult.ofPage(list.getContent(),list.getTotal());
    }

    /**
     * @param id
     * @return
     */
    @ApiOperation("获取奖项配置明细")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(awardService.getInfo(id));
    }

    /**
     * 创建｜修改赛程信息
     * @param param
     * @return
     */
    @ApiOperation("创建｜修改奖项配置信息")
    @PostMapping("/add-edit")
    public AjaxResult addOrEdit(@RequestBody AwardAddParam param) {
        awardService.addOrEdit(param);
        return AjaxResult.success();
    }

    @ApiOperation("删除奖项配置信息")
    @PostMapping("/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids) {
        return toAjax(awardService.deleteOrgInfo(ids));
    }

}
